package com.appwx.sdk.http;

import org.json.JSONException;
import org.json.JSONObject;

import com.appwx.sdk.view.WeiboException;

public class ParseResoneJson {

	public static JSONObject parseJson(String response) throws JSONException,
			NumberFormatException, WeiboException {
		if (response.equals("false")) {
			throw new WeiboException("request failed");
		}
		if (response.equals("true")) {
			response = "{value : true}";
		}
		if (response.endsWith(");")) {
			response = response.replaceAll("([a-z]*)\\(([^\\)]*)\\);", "$2");
			response = response.trim();
		}
		JSONObject json = new JSONObject(response);
		return json;
	}

}